package com.example.demo.controller;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.demo.base.BaseService;
import com.example.demo.dto.TestDTO;
import com.example.demo.po.TestPO;
import com.example.demo.query.TestQuery;
import com.example.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.example.demo.base.AbstractBaseController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cd
 * @since 2022-12-07
 */
@RestController
@RequestMapping("/test")
public class TestController extends AbstractBaseController<TestPO, TestDTO, TestQuery> {

    @Autowired
    private TestService testService;

    @Override
    public BaseService<TestPO> baseService() {
        return testService;
    }

    @Override
    protected Wrapper<TestPO> getPageWrappers(TestQuery query) {
        //1. 构建动态查询条件
        LambdaQueryWrapper<TestPO> queryWrapper = new LambdaQueryWrapper<>();
        if(query.getId() != null){
            queryWrapper.eq(TestPO::getId,query.getId());
        }
        return queryWrapper;
    }

}

